package com.zh.controller.app;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zh.pojo.domain.CustomerCar;
import com.zh.pojo.dto.CustomerCarDto;
import com.zh.pojo.query.PageQueryWrapper;
import com.zh.result.JSONResult;
import com.zh.result.PageResult;
import com.zh.service.ICustomerCarService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@Tag(name = "客户车辆",description = "客户车辆")
@RestController
@RequestMapping("app/customerCar")
public class AppCustomerCarController {

    @Autowired
    public ICustomerCarService customerCarService;

    //获取列表:PageQueryWrapper作为通用的查询对象
    @Operation( summary= "查询乘客车辆列表",description = "查询乘客车辆列表")
    @PostMapping(value = "/list/current")
    public JSONResult carList(){
        return JSONResult.success(customerCarService.carList());
    }

    @Operation( summary= "添加车辆信息",description = "添加车辆信息")
    @Parameter(name = "customerCarDto",description = "添加车辆的信息",required = true)
    @PostMapping("/addCar")
    public JSONResult addCar(@RequestBody @Valid CustomerCarDto customerCarDto){
        customerCarService.addCar(customerCarDto);
        return JSONResult.success();
    }
    //删除对象
    @Operation( summary= "删除单个车辆",description = "删除单个车辆")
    @Parameter(name = "id",description = "删除的对象ID",required = true)
    @DeleteMapping(value="deleteCar/{id}")
    public JSONResult delete(@PathVariable("id") Long id){
        return JSONResult.success(customerCarService.removeById(id));
    }

}
